package com.mall.page.web.controller;

import com.mall.common.util.RespResult;
import com.mall.page.web.service.IPageService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.FileNotFoundException;
import java.io.UnsupportedEncodingException;

/**
 * @author Darren
 * @date 2022-08-26 11:25
 * Description：
 */
@RestController
@RequestMapping("/page")
public class PageController {
    @Autowired
    private IPageService pageService;

    @GetMapping("/{spuId}")
    @ApiOperation(value = "商品详情静态页生成")
    public RespResult generateHtml(@PathVariable("spuId") String spuId)
            throws FileNotFoundException, UnsupportedEncodingException {
        pageService.generateHtml(spuId);
        return RespResult.ok();
    }
}
